#include <iostream>
#include <string>
using namespace std;

int N; string s;

int main(){
    cin >> s >> N;
    int left = 0, right = 0;
    int n = s.size();
    int count = 0;
    float ratio = 0;
    string ret;
    while (right < n ){
        while (right < n && right - left + 1 <= N){
            if (s[right] =='C' || s[right] =='G') count ++;
            right ++;
        }
        if (ratio < count / (float)N){
            ret = s.substr(left, N);
            ratio =  count / (float)N;
        } 
        if (s[left] == 'C' || s[left] == 'G') {
            count --;
        }
        left++;
    }
    cout << ret << endl;
    return 0;
}
